package com.smarthealthring.mm.presenter;

import android.util.Log;

import com.smarthealthring.mm.api.ApiRequest;
import com.smarthealthring.mm.base.BasePresenter;
import com.smarthealthring.mm.contract.HealthyContract;
import com.smarthealthring.mm.contract.PersonalContract;
import com.smarthealthring.mm.utils.ErrorHanding;
import com.smarthealthring.mm.utils.ToastUtil;

import java.util.Map;

/**
 * Created by bilibili on 2018/5/26.
 */

public class HealthyPresenter extends BasePresenter<HealthyContract.View> implements HealthyContract.Presenter {

    @Override
    public void syncData(Map<String, String> params) {
        addSubscribe(ApiRequest.syncData(params)
                .subscribe(response -> {
                    Log.e("syncData===","success");
                    mView.syncDataSuccess(response);
                }, throwable -> {
                    mView.syncDataFail();
                    Log.e("syncData===",throwable.toString());
                    ToastUtil.shortShow(ErrorHanding.handleError(throwable));
                }));
    }
}
